#include <iostream>
#include "ThreadPool.h"
#include "ThreadPool.cpp"
void test(void* arg)
{
	int a = *(int*)arg;
	cout <<"["<<this_thread::get_id()<<"]:"  << "         "<< a<<endl;
	std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}


int main()
{
#if 1
		ThreadPool<int> pool(1, 1000);

		for (int i = 0; i < 10000; i++)
		{
			int* t = (int*)malloc(4);
			*t = i + 100;
			pool.addTask(Task<int>(test, t));
			if (i > 100 && i <=150)
			{
				cout << "Current thread count:" << "-----------" << pool.getAliveNum();
				std::this_thread::sleep_for(std::chrono::milliseconds(1000));
			}
			else if (i > 150)
			{
				cout << "Current thread count:" << "-----------" << pool.getAliveNum();
				//std::this_thread::sleep_for(std::chrono::milliseconds(500));
			}
		}
#endif
	std::this_thread::sleep_for(std::chrono::milliseconds(600000));
	cout << "ttttttttttttttttttttttt";
	return 0;
}